from django.db import models

import django.utils.timezone as timezone


class Student(models.Model):  # 学生
    Name = models.CharField(max_length=15)
    Gender = models.CharField(max_length=2, null=True)  # 性别
    Age = models.CharField(max_length=3, null=True)
    Account = models.CharField(max_length=16, primary_key=True)  # 账号
    Psw = models.CharField(max_length=16)  # 密码
    Email = models.EmailField(blank=False, unique=True)
    Motto = models.CharField(max_length=50, null=True)  # 个性签名
    Pic = models.ImageField(upload_to='img', null=True)
    Class = models.CharField(max_length=10, null=True)
    remarks = models.CharField(max_length=20, null=True)


class Teacher(models.Model):  # 老师
    Name = models.CharField(max_length=15)
    Gender = models.CharField(max_length=2, null=True)  # 性别
    Age = models.CharField(max_length=3, null=True)
    Account = models.CharField(max_length=16, primary_key=True)
    Psw = models.CharField(max_length=16)  # 密码
    Email = models.EmailField(blank=False, unique=True)
    Motto = models.CharField(max_length=50)  # 个性签名
    Pic = models.ImageField(upload_to='img', null=True)
    Class = models.CharField(max_length=10, null=True)
    remarks = models.CharField(max_length=20)


class Class(models.Model):
    tch_account = models.CharField(max_length=16, primary_key=True)
    className = models.CharField(max_length=255, unique=True, default='xautclass')
    peopleNum = models.IntegerField(default=100)
    totalChoiceRight = models.IntegerField(null=True)
    totalChoiceWrong = models.IntegerField(null=True)
    totalCompletionRight = models.IntegerField(null=True)
    totalCcompletionWrong = models.IntegerField(null=True)
    totalShortAnswerRight = models.IntegerField(null=True)
    totalShortAnswerWrong = models.IntegerField(null=True)


class personalReport(models.Model):
    stu_account = models.CharField(max_length=10, primary_key=True)
    choiceRight = models.IntegerField(null=True)
    choiceWrong = models.IntegerField(null=True)
    completionRight = models.IntegerField(null=True)
    completionWrong = models.IntegerField(null=True)
    shortAnswerRight = models.IntegerField(null=True)
    shortAnswerWrong = models.IntegerField(null=True)


class Administrator(models.Model):  # 管理员
    Name = models.CharField(max_length=15)
    Account = models.CharField(max_length=16, primary_key=True)
    Psw = models.CharField(max_length=16)
    remarks = models.CharField(max_length=20, null=True)


class log(models.Model):
    date = models.DateTimeField(default=timezone.now)
    operator = models.CharField(max_length=16)
    operationType = models.CharField(max_length=2)  # 操作类型
    project = models.CharField(max_length=25)  # 操作项目
    detail = models.CharField(max_length=100)
    remarks = models.CharField(max_length=20)


class databaseInfo(models.Model):
    date = models.DateTimeField()
    path = models.CharField(max_length=255)  # 备份所在的路径


class comment(models.Model):
    speakerAccount = models.CharField(max_length=16)
    date = models.DateTimeField(null=True)
    thumbUp = models.IntegerField(null=True)
    thumDown = models.IntegerField(null=True)
    floor = models.IntegerField()  # 评论楼层
    content = models.CharField(max_length=255)


class personalQB(models.Model):
    TypeID = models.IntegerField(null=True)  # 题型ID， 选择为1， 填空为2， 简答为3
    questionID = models.CharField(max_length=255)  # 问题ID
    statusID = models.IntegerField()  # 答题状态ID, 答对为1， 答错为0， 不答为-1
    Account = models.CharField(max_length=16)  # 学生账号，为主键
    rightAnswer = models.CharField(max_length=255)  # 这道题的正确答案
    wrongAnswer = models.CharField(max_length=255)  # 如果学生答错了，此栏填写学生的答案
    question = models.CharField(max_length=255)  # 问题原题
